using UnityEngine;
using System.Collections;

public class ButtonControlAnimationPlay : MonoBehaviour {
	
	public GameObject animationTarget;
	
	Animation targetAnimation;
	// Use this for initialization
	void Start () {
		targetAnimation = animationTarget.GetComponent<Animation>();
		
		targetAnimation["idle"].wrapMode = WrapMode.Loop;
		
		targetAnimation["skillAttack"].wrapMode = WrapMode.ClampForever;
		
		targetAnimation.Stop();
		targetAnimation.Play("skillAttack");
	}
	
	void Update(){
		if(!targetAnimation.IsPlaying("skillAttack"))
			targetAnimation.CrossFade("idle",0.1f);
	}
	
	void OnClick(){
		targetAnimation.CrossFade("skillAttack",0.1f);
	}
}
